<template>
  <div class="common_wrap">
    <div class="common_title">镇(街)指标管理/最新异常数据</div>
    <el-table ref="table" v-loading="tableLoading" :data="tableData">
      <el-table-column
        prop="quotaId"
        label="指标ID"
        align="center"
        width="80"
      />
      <el-table-column
        prop="periodNo"
        label="导入期号"
        align="center"
        width="80"
      />
      <el-table-column
        prop="issueStartNo"
        label="开始期号"
        align="center"
        width="80"
      />
      <el-table-column
        prop="issueEndNo"
        label="结束期号"
        align="center"
        width="80"
      />
      <el-table-column
        prop="quotaName"
        label="指标名称"
        align="center"
        width="120"
      />
      <el-table-column
        prop="dimension"
        label="维度"
        align="center"
        width="100"
      />
      <el-table-column
        prop="unitValue"
        label="数值"
        align="center"
        width="100"
      />
      <el-table-column prop="unit" label="计量" align="center" width="100" />
      <el-table-column
        prop="areaName"
        label="区域"
        align="center"
        width="100"
      />
      <el-table-column
        prop="streetName"
        label="镇(街)"
        align="center"
        width="100"
      />
      <el-table-column
        prop="quotaType"
        label="指标类型"
        align="center"
        width="100"
      />
      <el-table-column
        prop="empName"
        label="责任领导"
        align="center"
        width="120"
      />
      <el-table-column prop="signage" label="赋牌" align="center" width="60">
        <template slot-scope="scope">
          <span :class="formateColor(scope.row.signage)">{{
            formateCard(scope.row.signage)
          }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="reason" label="原因" align="center" width="220" />
    </el-table>
    <el-pagination
      class="pagination-container"
      :background="true"
      :current-page="queryParams.current"
      :page-sizes="[10, 20, 30, 40, 50]"
      :page-size="queryParams.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="sizeChange"
      @current-change="currentChange"
    />
  </div>
</template>



<script>
export default {
  data() {
    return {
      tableData: [],
      queryParams: {
        page: 1, // 第几页
        size: 10, // 每页条数
      },
      total: 0,
      tableLoading: false,
    };
  },
  computed: {
    formateColor() {
      return function (card) {
        const cardNum = card / 1;
        switch (cardNum) {
          case 0:
            return "green";
          case 1:
            return "red";
          default:
            return "blue";
        }
      };
    },
    formateCard() {
      return function (card) {
        const cardNum = card / 1;
        switch (cardNum) {
          case 0:
            return "绿";
          case 1:
            return "红";
          default:
            return "蓝";
        }
      };
    },
  },
  created() {
    this.getTableData();
  },
  methods: {
    getTableData() {
      this.$api.streetErrorData(this.queryParams).then((res) => {
        if (res.status == 200) {
          this.tableData = res.data.data.records;
          this.total = res.data.data.total;
        }
      });
    },
    sizeChange(size) {
      this.queryParams.size = size;
      this.queryParams.page = 1;
      this.getTableData();
    },
    // 当前页变化
    currentChange(current) {
      this.queryParams.page = current;
      this.getTableData();
    },
  },
};
</script>



<style scoped>
.flex {
  display: flex;
}
.edit_box .date {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
}
.edit_box .date > div:first-child {
  color: #333;
  width: 100px;
  text-align: right;
}
.edit_box .quota_info {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
}
.edit_box .quota_info .left > div:first-child,
.edit_box .quota_info .right > div:first-child {
  color: #333;
  width: 100px;
  text-align: right;
}
.edit_box .quota_info .left > div:last-child,
.edit_box .quota_info .right > div:last-child {
  width: 100px;
}
.edit_box .inx_box .left {
  font-size: 14px;
  color: #666;
  margin-bottom: 15px;
}
.edit_box .inx_box .left .tit {
  height: 28px;
  line-height: 28px;
  color: #333;
  width: 100px;
  text-align: right;
}
.edit_box .inx_box .left .old {
  width: 60px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  background-color: #efefef;
  border: 1px solid #dcdcdc;
  margin-right: 20px;
}
.edit_box .inx_box .change {
  height: 28px;
  line-height: 28px;
  color: #2689fd;
  margin-right: 20px;
}
.edit_box >>> .el-input__inner {
  padding-right: 0;
}
.edit_box .inx_box .right {
  margin-left: 20px;
}
.edit_box .inx_box .right .tit {
  height: 28px;
  line-height: 28px;
  color: #333;
  margin-right: 20px;
}
.edit_box .inx_box .right .card {
  width: 50px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  color: #fff;
  background-color: #4ca5f1;
  margin-right: 20px;
}
.edit_box .inx_box .right .card.green {
  background-color: #5bc55a;
}
.edit_box .inx_box .right .card.red {
  background-color: #e43c26;
}
.edit_box .dgree_box .tit {
  color: #333;
  width: 100px;
  height: 28px;
  line-height: 28px;
  text-align: right;
}
.edit_box .dgree_box .content .tit {
  width: 60px;
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  margin-bottom: 20px;
  color: #666;
}
.blue {
  color: #4ca5f1;
}
.green {
  color: #5bc55a;
}
.red {
  color: #e43c26;
}
</style>